package program;

import gamemodels.MainMenuModel;

import java.awt.AWTException;

import javax.swing.JOptionPane;

import view.View;

/**
 * The Game.
 * @author Team Deer
 * 
 */
public class AmazingMazeGame {

	/**
	 * Starts one game of Amazing Maze
	 */
	public AmazingMazeGame() {
		
		final View view = View.getInstance();
		
		try {
			
			GameController.addInputManager(view.getCanvas());
			final MainMenuModel menu = MainMenuModel.getInstance();
			view.load(menu);
			GameController.run(menu);
			
		} catch (final AWTException e) {
			/*
			 * If this Exception is caused by any reason the inputManager can't
			 * get any inputs. That means the application must exit.
			 */
			JOptionPane.showMessageDialog(view, e.getMessage(), e.toString(),
					JOptionPane.ERROR_MESSAGE);
		} finally {
			view.dispose();
		}
	}
	
}
